<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html"; charset="utf-8">
<title>login </title>
</head>
<body>
<script src="jquery-3.7.0.min.js"></script>

<form action="http://127.0.0.1/index.php?a=login&b=index" method="POST">
	用户名</br>
	<input name='username' id='username' value=''>
	</br>密码</br>
	<input name='password' id='password' value='' type='password'>
	<p></p>
</form>
<input value='login' type='submit' onclick="login();">

<script>
function login()
{
	var username = document.getElementById('username').value;
	var passwd = document.getElementById('password').value;
	var data = 
	{
		'username':username,
		'password':passwd
	};
	$.ajax({
		type:'post',
		url:'./index.php?a=login&b=index',
		data:data,
		dataType:'text',
		success:function(result){
			result = JSON.parse(result)
			console.log(result);
			alert(result.msg);
			if (result.url !='')
			{
				window.location.href = result.url;
			}
		}
	});

}

</script>


</body>
</html>